package com.asiainfo.lop;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.support.v4.app.ActivityCompat;
import android.widget.TextView;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

/**
 * Created by wucm(wucm@asiainfo.com) on 2016/5/31 16:10.
 */
@EActivity(R.layout.message_deal)
public class MessageDealActivity extends BaseActivity {
    @ViewById(R.id.top_bar_tv)
    TextView topbarTv;

    @ViewById(R.id.message_deal_phone)
    TextView messageDealPhoneTv;

    @Click({R.id.btn_back_iv, R.id.btn_back_tv, R.id.message_deal_cancel})
    void back() {
        this.finish();
    }

    @AfterViews
    void setTopBarTv() {
        topbarTv.setText("消息处理");
    }

    /**
     * 打电话
     */
    @Click(R.id.message_deal_call)
    void call() {
        String phoneNum = messageDealPhoneTv.getText().toString();
        Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNum));
        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
            return;
        }
        startActivity(intent);
    }

    /**
     * 发短信
     */
    @Click(R.id.message_deal_sms)
    void sms() {
        String message = "";
        String phoneNum = messageDealPhoneTv.getText().toString();
        Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + phoneNum));
        intent.putExtra("sms_body", message);
        startActivity(intent);
    }

    /**
     * 处理信息反馈
     */
    @Click(R.id.message_deal_feedback)
    void feedback(){
        Intent indent = new Intent(this, MessageFeedbackActivity_.class);
        startActivity(indent);
    }
}
